package demo;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import static com.sun.deploy.util.SessionState.init;

public class Scan {
    private static String classPath = null;

    private static List<String> list = new ArrayList<String>();

    public List<String> come(String path) {
        path = path.replace(".", File.separator);
        classPath = Thread.currentThread().getContextClassLoader().getResource("").getPath()+path;
        init(classPath);
        return list;
    }
    private static void init(String path){
        File f = new File(path);
        File[]files = f.listFiles();
        for (File f1:files){
            if (f1!=null){
                if (f1.isFile()){
                    String  p = f1.getAbsolutePath();
                    String s = subPath(p);
                    list.add(s);
                }else{
                    init(f1.getAbsolutePath());
                }

            }
        }

    }

    private static String subPath(String ppq) {
        String pt = ppq.replace(Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(1).replace("/", "\\"), "").replace("\\", ".").replace(".class", "");
        return pt;
    }
}
